﻿@{
    ViewBag.Title = "Ban quản trị - Quản lý danh mục";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section JavaScriptCSSImport{
    <link href="@Url.Content("~/Content/mycontent/list_counter.css")" rel="stylesheet" type="text/css"/>
}

@section JavaScriptDocumentReady{
    $('#danhSachDanhMuc').jtable({
            tableId: "tableDanhMuc",
            title: 'Danh sách danh mục',
            pageSize: 10,
            paging: true,
            sorting: true,
           defaultSorting: 'TenDanhMuc ASC',
            selecting: true, //Enable selecting
            //multiselect: true, //Allow multiple selecting
            //selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Admin/DanhSachDanhMuc',
                deleteAction: '/Admin/XoaDanhMuc',
                updateAction: '/Admin/CapNhatDanhMuc',
                createAction: '/Admin/ThemDanhMuc'
            },

            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false
                },
                TenDanhMuc : {
                    title: 'Tên danh mục',
                    width: '25%',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true,
                    listClass: "td_autohide"
                },
                SoLuongTrongDanhMuc : {
                    title: 'Số lượng',
                    create: false,
                    edit: false,
                    list: true,
                    sorting: true,
                    listClass: "td_autohide"
                },
                Xoa: {
                    title: 'Trạng thái',
                    create: false,
                    edit: true,
                    list: true,
                    sorting: true,
                    type: 'checkbox',
                    values: { 'false': 'Hoạt động', 'true': 'Bị xóa' },
                }
                
               
            }
        });

        //Load student list from server
        $('#danhSachDanhMuc').jtable('load');
        //$('table.jtable').css("table-layout","fixed");

        //Filter
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#danhSachDanhMuc').jtable('load', {
                name: $('#name').val(),
                cityId: $('#cityId').val()
            });
        });
}

<!-- Container for jTable -->
<div id="danhSachDanhMuc"></div>
